package org.theSeed.dataSource.pojo.sysEnum;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

/**
 * spring托管数据源类型
 */
public enum SeedSpringDataSourceType {
    SINGLE("single","单一数据源"),

    DYNAMIC("dynamic","动态数据源"),
    ;
    SeedSpringDataSourceType(String type, String describStr) {
        this.type = type;
        this.describStr = describStr;
    }

    /**
     * 编码
     */
    @Getter
    private String type;

    /**
     * 描述字符
     */
    @Getter
    private String describStr;

    /**
     * 获取实例
     * @param type
     * @return
     */
    public static SeedSpringDataSourceType getInstance(String type){
        if (ObjectUtil.isEmpty(type)){
            return null;
        }

        for (SeedSpringDataSourceType item : values()) {
            if (item.type.equals(type))
                return item;
        }
        return null;
    }
}
